package com.totoro.mongo;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;

/**
 * Created by Niki on 2018/3/28 17:41
 */
public class MongoUtil {
    private MongoUtil() {
    }

    private static MongoClient client;

    static {
        client = new MongoClient("127.0.0.1", 27017);
    }

    public static MongoClient getClient() {
        return client;
    }

    public static void closeClient(MongoClient client) {
        client.close();
    }

    public static MongoDatabase getDataBase(MongoClient client, String databaseName) {
        return client.getDatabase(databaseName);
    }
}
